package top.shen33.yang.controller;

import org.springframework.web.multipart.MultipartFile;
import top.shen33.yang.base.R;
import top.shen33.yang.model.entity.RbacUserRole;
import top.shen33.yang.services.RbacUserRoleService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author oreilly
 * @since 2018-08-23
 */
@RestController
@RequestMapping("/rbacUserRole")
    public class RbacUserRoleController extends BaseController<RbacUserRole> {


            @Autowired
            private RbacUserRoleService rbacUserRoleService;




            @Override
            public Object doAdd(@RequestBody RbacUserRole rbacUserRole) throws Exception {

                    rbacUserRoleService.doAdd(rbacUserRole);
                    return R.ok(rbacUserRole);
            }

            @Override
            public Object deDelete(String[] ids) throws Exception {

                    rbacUserRoleService.doDelete(ids);
                    return R.ok("delete ok");
            }

            @Override
            public Object doUpdate(@RequestBody RbacUserRole rbacUserRole) throws Exception {

                    rbacUserRoleService.doUpdate(rbacUserRole);
                    return R.ok(rbacUserRole);
            }

            @Override
            public Object getOne(@PathVariable String id) throws Exception {
                    RbacUserRole rbacUserRole = rbacUserRoleService.getOne(id);
                    return R.ok(rbacUserRole);
            }


            public Object all(RbacUserRole rbacUserRole) throws Exception{
                    List<RbacUserRole> rbacUserRoleList = rbacUserRoleService.all(rbacUserRole);
                    return R.ok(rbacUserRoleList);
            }

        @Override
        public void exportExcel(HttpServletResponse response, RbacUserRole rbacUserRole) throws Exception {

        }

        @Override
        public Object importExcel(MultipartFile file) throws Exception {
                return null;
        }

        @Override
            public Object pageInfo(Page page, RbacUserRole rbacUserRole) throws Exception {

                    Page<RbacUserRole> rbacUserRolePage = rbacUserRoleService.pageInfo(page, rbacUserRole);
                    return R.ok("page",rbacUserRolePage);
            }


        }

